import { connect, Connection } from "amqplib";

export async function useMq(): Promise<Connection> {
    try {
        const mqUrl = process.env.MQ_URL || ``
        const con = await connect(mqUrl)
        return con;
    } catch (e) {
        console.log(`链接失败，重新链接 ${(e as Error).message} ${process.env.MQ_URL}`)
        await new Promise((resolve, reject) => {
            setTimeout(resolve, 1000)
        })
        return useMq();
    }
}